package cc.ufinity.networkdiagnose.manager;

import android.app.Activity;
import android.graphics.Bitmap;
import android.view.Display;
import android.view.View;

public final class ShotManager {
	private Activity ctx;
	
	public ShotManager(Activity context){
		this.ctx = context;
	}

	public Bitmap shot() {
		View view = ctx.getWindow().getDecorView();
		Display display = ctx.getWindowManager().getDefaultDisplay();
		view.layout(0, 0, display.getWidth(), display.getHeight());
		view.setDrawingCacheEnabled(true);// 允许当前窗口保存缓存信息，这样getDrawingCache()方法才会返回一个Bitmap
		Bitmap bmp = Bitmap.createBitmap(view.getDrawingCache());
		return bmp;
	}
}
